<template>
    <div id="article-content">
        <g-admin></g-admin>
        <h1>论坛分楼层信息</h1>
        <el-table :data="content" border="true" style="width: 100%">
            <el-table-column prop="forumID" label="论坛编号" width="150px"></el-table-column>
            <el-table-column label="用户姓名" prop="username"></el-table-column>
            <el-table-column label="内容" prop="content"></el-table-column>
            <el-table-column label="回复时间" prop="replyTime"></el-table-column>
            <el-table-column label="楼层" prop="floorIndex"></el-table-column>
            <el-table-column label="操作" width="180px">
                <template slot-scope="scope">
                    <!-- 编辑按钮 -->
                    <el-button >审核留言内容</el-button>
                    <el-button @click="deleteArticle(scope.row['floorIndex'])" type="danger" size="small">删除该楼层</el-button>
                    <el-button @click="edit(scope.row['username'])" type="text" size="small">修改信誉分</el-button>
                </template>
            </el-table-column>
        </el-table>



    </div>
</template>

<script>
    import GAdmin from '../../components/gadmin/GAdmin';
    import axios from 'axios'
    export default {
        name: "article-content",
        components:{
            GAdmin
        },
        created(){
            this.forumID = this.$route.query.forumID;
            this.requestForMessage(this.forumID);
        },
        data(){
            return{
                forumID:'',
                content:''
            }
        },
        mounted(){
            document.querySelector('.tabbar').setAttribute('style','display:none');
            document.querySelector('.gfooter').setAttribute('style','display:none');
        },
        methods:{
            requestForMessage(forumID){
                //获取论坛分楼层内容
                this.request({
                    url:'/forum/getfloor/'+forumID
                }).then(res=>{
                    this.content = res.data;
                }).catch(err=>{
                    console.log(err);
                });
            },
            deleteArticle(floorIndex){
                this.request({
                    url:'/forum/deletefloor/'+this.forumID+'/'+floorIndex
                }).then(res=>{
                    alert("删除该楼层成功");
                }).catch(err=>{
                    console.log(err);
                });
            },
            edit(username){
                this.$router.push({
                    path:'/admin/admin/update',
                    query:{
                        userName:username
                    }}).catch(error=>error)
            }
        }
    }
</script>

<style scoped>
    #article-content{
        margin-left: 130px;
        margin-top: 20px;
    }

</style>